package com.ruoyi.goods.service.impl;


import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.goods.domain.OrderDetails;
import com.ruoyi.goods.domain.Sales;
import com.ruoyi.goods.mapper.OrderDetailsMapper;
import com.ruoyi.goods.mapper.SalesMapper;
import com.ruoyi.goods.service.IOrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 订单详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-11
 */
@Service
public class OrderDetailsServiceImpl implements IOrderDetailsService
{
    @Autowired
    private OrderDetailsMapper orderDetailsMapper;

    @Autowired
    private SalesMapper salesMapper;
    /**
     * 查询订单详情
     * 
     * @param id 订单详情主键
     * @return 订单详情
     */
    @Override
    public OrderDetails selectOrderDetailsById(Long id)
    {
        return orderDetailsMapper.selectOrderDetailsById(id);
    }

    /**
     * 查询订单详情列表
     * 
     * @param orderDetails 订单详情
     * @return 订单详情
     */
    @Override
    public List<OrderDetails> selectOrderDetailsList(OrderDetails orderDetails)
    {
        return orderDetailsMapper.selectOrderDetailsList(orderDetails);
    }

    /**
     * 新增订单详情
     * 
     * @param orderDetails 订单详情
     * @return 结果
     */

    @Override
    public int insertOrderDetails(OrderDetails orderDetails)
    {
       
        String replaceUUID = UUID.randomUUID().toString().replace("-", "");
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
        String formattedDate = sdf.format(date);
        orderDetails.setDatatime(formattedDate);
        orderDetails.setOrderId(replaceUUID);
        return orderDetailsMapper.insertOrderDetails(orderDetails);
    }

    /**
     * 修改订单详情
     * 
     * @param orderDetails 订单详情
     * @return 结果
     */
    @Override
    public int updateOrderDetails(OrderDetails orderDetails)
    {
        return orderDetailsMapper.updateOrderDetails(orderDetails);
    }

    /**
     * 批量删除订单详情
     * 
     * @param ids 需要删除的订单详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailsByIds(Long[] ids)
    {
        return orderDetailsMapper.deleteOrderDetailsByIds(ids);
    }

    /**
     * 删除订单详情信息
     * 
     * @param id 订单详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailsById(Long id)
    {
        return orderDetailsMapper.deleteOrderDetailsById(id);
    }
}
